import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class demo10 {
    public static void main(String[] args) {
        //想要保留之前的，也需要加 true
        try(Writer writer = new FileWriter("./test.txt",true)) {
            String str = "hello World!";
            writer.write(str);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
